package com.team.recruitment_management_system.controller;

import com.team.recruitment_management_system.pojo.dto.hr.AddHrInfoDto;
import com.team.recruitment_management_system.pojo.dto.hr.ChangeHrInfoDto;
import com.team.recruitment_management_system.pojo.dto.hr.HrPageQuery;
import com.team.recruitment_management_system.pojo.vo.HrInfoVo;
import com.team.recruitment_management_system.security.OperationLogAnnotation;
import com.team.recruitment_management_system.service.HrService;
import com.team.recruitment_management_system.util.result.PageResult;
import com.team.recruitment_management_system.util.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hr")
@Tag(name = "hr模块")
public class HrController {
    @Autowired
    private HrService hrService;

    @PostMapping("/one")
    @Operation(summary = "添加hr", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "插入", operDesc = "添加hr")
    public Result<Void> addHrInfo(@RequestBody @Validated AddHrInfoDto addHrInfoDto) {
        return hrService.addHrInfo(addHrInfoDto);
    }

    @PutMapping("/one")
    @Operation(summary = "修改hr", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "修改", operDesc = "修改hr")
    public Result<Void> addHrInfo(@RequestBody @Validated ChangeHrInfoDto changeHrInfoDto) {
        return hrService.changeHrInfo(changeHrInfoDto);
    }

    @DeleteMapping("/one/{id}")
    @Operation(summary = "根据ID删除hr", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "删除", operDesc = "根据ID删除hr")
    public Result<Void> deleteHrById(@PathVariable int id) {
        return hrService.deleteHrById(id);
    }

    @GetMapping("/one/{id}")
    @Operation(summary = "根据ID获取hr", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "查询", operDesc = "根据ID获取hr")
    public Result<HrInfoVo> getHrInfoById(@PathVariable int id) {
        return hrService.getHrInfoById(id);
    }

    @GetMapping("/isHr/{id}")
    @Operation(summary = "根据ID判断是否为hr", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "查询", operDesc = "根据ID判断是否为hr")
    public Result<Integer> isHr(@PathVariable int id) {
        return hrService.isHr(id);
    }

    @GetMapping("/me")
    @Operation(summary = "获取自己的hr信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<HrInfoVo> getMyHrInfo(@RequestHeader String Authorization) {
        return hrService.getMyHrInfo(Authorization);
    }

    @GetMapping("/more")
    @Operation(summary = "获取hr分页", security = {@SecurityRequirement(name = "Authorization")})
    @OperationLogAnnotation(operModul = "hr模块", operType = "查询", operDesc = "获取hr分页")
    public PageResult<HrInfoVo> getHrInfoPage(HrPageQuery hrPageQuery) {
        return hrService.getHrInfoPage(hrPageQuery);
    }

}
